package ph.com.gs3.formalistics.presenter.fragments.views;

import ph.com.gs3.formalistics.R;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class SupportViewFragment extends Fragment {

	public static final String TAG = SupportViewFragment.class.getSimpleName();

	private TextView tvErrorCount;
	private TextView tvWarningCount;
	private Button bReportIssues;

	private SupportViewActionListener listener;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			listener = (SupportViewActionListener) activity;
		} catch (ClassCastException e) {
			throw new IllegalStateException(activity.getClass().getSimpleName()
			        + " must implement SupportViewActionListener");
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_support, container, false);

		tvErrorCount = (TextView) rootView.findViewById(R.id.Support_tvErrorCount);
		tvWarningCount = (TextView) rootView.findViewById(R.id.Support_tvWarningCount);
		bReportIssues = (Button) rootView.findViewById(R.id.Support_bSendIssues);

		tvErrorCount.setText("");
		tvWarningCount.setText("");

		bReportIssues.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View view) {
				if (listener != null) {
					listener.onReportIssues();
				}
			}
		});

		return rootView;
	}

	public static interface SupportViewActionListener {
		public void onReportIssues();
	}

}
